<template>
  <div style="height:100%;width:100%">
    <el-row class="mainContent" >
      <!--工具条-->
      <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
        <el-form :inline="true" :model="filters" size="small" style="text-align:left;" :rules="filte" ref="filters">
          <el-form-item prop="id">
            <el-input v-model="filters.username" placeholder="手机号" clearable></el-input>
          </el-form-item>
          <el-form-item>
            <div class="block">
              <el-date-picker
                v-model="filters.begtime"
                type="datetime"
                placeholder="申请开始日期">
              </el-date-picker>
              <el-date-picker
                v-model="filters.endtime"
                type="datetime"
                placeholder="申请结束日期">
              </el-date-picker>
            </div>
          </el-form-item>
          <el-form-item>
            <el-button type="primary"  @click="getUsers">查询</el-button>
          </el-form-item>
        </el-form>
      </el-col>
      <!--列表-->
      <el-table :data="users" highlight-current-row  v-loading="listLoading" style="width: 100%;">
        <el-table-column label="ID" prop="id">
        </el-table-column>
        <el-table-column label="手机号" prop="username">
        </el-table-column>
        <el-table-column label="资金总额" prop="amount">
        </el-table-column>
        <el-table-column  label="保证金"  prop="amountBond">
        </el-table-column>
        <!--<el-table-column  label="交易账号" prop="subUsername">-->
        <!--</el-table-column>-->
        <!--<el-table-column  label="审核管理员" prop="adminUserCode">-->
        <!--</el-table-column>-->
        <el-table-column label="申请时间" prop="applytime">
        </el-table-column>
        <!--<el-table-column  label="审核时间" prop="settletime">-->
        <!--</el-table-column>-->
        <!--<el-table-column  label="类型" >-->
          <!--<template slot-scope="scope">-->
            <!--{{scope.row.type | typeFormat}}-->
          <!--</template>-->
        <!--</el-table-column>-->
        <!--<el-table-column  label="状态" >-->
          <!--<template slot-scope="scope">-->
            <!--{{scope.row.state | stateFormat}}-->
          <!--</template>-->
        <!--</el-table-column>-->
        <el-table-column  label="操作" width="150" v-if="$store.state.routes.routes.sqjsapply || $store.state.routes.routes.qxjsapply">
          <template slot-scope="scope">
            <el-button v-if="$store.state.routes.routes.sqjsapply"
              size="mini"
              type="success"
              @click="todo(scope.$index,scope.row,1)">结算</el-button>
            <el-button v-if="$store.state.routes.routes.qxjsapply"
              size="mini"
              type="danger"
              @click="todo(scope.$index,scope.row,2)">取消</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination layout="prev, pager, next" @current-change="handleCurrentChange" :page-size="10"  :total="total" style="float:right;">
      </el-pagination>
    </el-row>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        filters: {
          username:'',
          begtime:'',
          endtime:"",
        },
        form:{},
        editFormRules:{},
        users:[],
        page: 1,
        total: 0,
        listLoading: false,
        filte:{},
        dialogFormVisible:false,
        editPwdLoading:false
      };
    },
    created() {
      this.getUsers();
    },
    methods: {
      getUsers() {
        this.users = []
        this.listLoading = true;
        var obj = {
          data:{
            username:this.filters.username,
            state:14,
            begtime:this.filters.begtime==''||this.filters.begtime==0||this.filters.begtime==null?'':Math.round(new Date(this.filters.begtime).getTime()/1000),
            endtime:this.filters.endtime==''||this.filters.endtime==0||this.filters.endtime==null?'':Math.round(new Date(this.filters.endtime).getTime()/1000),
            pageNo:this.page,
          }
        };
        this.$http('sys/financing/list.do',obj).then(resp => {
          if(resp.code==1){
            this.users = resp.data.list;
            this.total = resp.data.total
          }
          this.listLoading = false;
        });

      },
      handleCurrentChange(val) {
        this.page = val;
        this.getUsers();
      },
      todo(index,row,type){
        if(!this.$store.state.routes.routes.sqjsapply){
          this.$message({
            message:'无权限',
            type:'error'
          })
          return
        }
        if(!this.$store.state.routes.routes.qxjsapply){
          this.$message({
            message:'无权限',
            type:'error'
          })
          return
        }
        var str = '结算'
        var url = 'sys/financeAccount/liquidation.do'
        if(type == 2){
          str = '取消'
          url = "sys/financeAccount/refuseLiquidation.do"
        }
        this.$confirm("确认"+str+"么吗?", "提示", {})
          .then(() => {
            this.$http(url,{data:{cingId:row.id}}).then(resp=>{
              if(resp.code==1){
                this.$message({
                  message:resp.msg,
                  type:'success'
                })
              }else{
                this.$message({
                  message:resp.msg,
                  type:'eror'
                })
              }
              this.getUsers()
            })
          })
          .catch(() => {});

      }
    }
  };
</script>

<style scoped>
  .rights{
    float:right
  }

  .el-table:hover{
    cursor: pointer !important;
  }
</style>
